package cn.itsource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import static cn.itsource.RabbitmqConfig.EXCHANGE_TOPICS_INFORM;
import static cn.itsource.RabbitmqConfig.QUEUE_INFORM_EMAIL;

//消息发送者
@SpringBootTest(classes = App.class)
@RunWith(SpringRunner.class)
public class send {
    //注入rabbit的工具
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Test
    public void test()throws Exception{
        //定义一个消息 convertAndSend(String exchange, String routingKey, Object message
       String message="this is s message";
        rabbitTemplate.convertAndSend(EXCHANGE_TOPICS_INFORM,QUEUE_INFORM_EMAIL,message);
        System.out.println("消息发送成功");
    }
}
